<?php
function generate_view($layout, $view, $module) {
	if(!file_exists(app_path() . '/views/' . $view . '-' . $module . '.blade.php')) {
		$content = file_get_contents(app_path() . '/views/layout/' . $layout . '/' . $module . '.blade.php', 'r');
		$fp = fopen(app_path() . '/views/' . $view . '-' . $module . '.blade.php', 'w+');
		fwrite($fp, $content);
		fclose($fp);

		return $view . '-' . $module;
	}
	return $view . '-' . $module;
}

function genearate_model($table, $model) {
	if(!file_exists(app_path() . '/models/' . $model . '.php') && ($table != '[]' && $table != '') && ($model != '[]' && $model != '')) {
		$content  = "<?php\n\n";
		$content .=	"class " . $model . " extends Eloquent {\n\n";
		$content .= "\t protected \$table = '$table';\n\n";
		$content .= "}";

		$fp = fopen(app_path() . '/models/' . $model . '.php', 'w');
		fwrite($fp, $content);
		fclose($fp);
	}
}

function generate_language($local, $name) {
	if(!file_exists(app_path() . '/lang/' . $local . '/' . $name . '.php')) {
		$content = file_get_contents(app_path() . '/lang/' . $local . '/default.php', 'r');
		$content = str_replace('Title', ucwords($name), $content);
		$fp = fopen(app_path() . '/lang/' . $local . '/' . $name . '.php', 'w+');
		fwrite($fp, $content);
		fclose($fp);
	}
}